/**
 * @method Micro 子应用统一封装、接收主应用数据的方法
 * @param setGlobalState 主应用暴露给子应用的方法setGlobalState,子应用要调用主应用的方法，通过此方法进行调用
 */
class Micro {
  instance: any
  mainApp: any
  render: any
  setGlobalState: any
  constructor() {
    this.instance = null
    this.render = function() {}
    this.setGlobalState = function() {}
  }
  setStore(props: any) {
    this.setGlobalState = props.setGlobalState
  }
  bootstrap() {
    console.log('[vue] vue app bootstraped')
  }
  mount(props: any) {
    console.log('[vue] props from main framework', props)
    this.setStore(props)
    this.render(props)
  }
  unmount() {
    this.instance.$destroy()
    this.instance = null
  }
}

const micro = new Micro()
export default micro
